package com.ruoyi.wlxz.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wlxz.domain.WxzSupplementRecord;
import com.ruoyi.wlxz.service.IWxzSupplementRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学分补录Controller
 * 
 * @author 张浩
 * @date 2025-07-21
 */
@RestController
@RequestMapping("/wlxz/record")
public class WxzSupplementRecordController extends BaseController
{
    @Autowired
    private IWxzSupplementRecordService wxzSupplementRecordService;

    /**
     * 查询学分补录列表
     */
    @PreAuthorize("@ss.hasPermi('wlxz:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(WxzSupplementRecord wxzSupplementRecord)
    {
        startPage();
        List<WxzSupplementRecord> list = wxzSupplementRecordService.selectWxzSupplementRecordList(wxzSupplementRecord);
        return getDataTable(list);
    }

    /**
     * 导出学分补录列表
     */
    @PreAuthorize("@ss.hasPermi('wlxz:record:export')")
    @Log(title = "学分补录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WxzSupplementRecord wxzSupplementRecord)
    {
        List<WxzSupplementRecord> list = wxzSupplementRecordService.selectWxzSupplementRecordList(wxzSupplementRecord);
        ExcelUtil<WxzSupplementRecord> util = new ExcelUtil<WxzSupplementRecord>(WxzSupplementRecord.class);
        util.exportExcel(response, list, "学分补录数据");
    }

    /**
     * 获取学分补录详细信息
     */
    @PreAuthorize("@ss.hasPermi('wlxz:record:query')")
    @GetMapping(value = "/{supplementId}")
    public AjaxResult getInfo(@PathVariable("supplementId") Long supplementId)
    {
        return success(wxzSupplementRecordService.selectWxzSupplementRecordBySupplementId(supplementId));
    }

    /**
     * 新增学分补录
     */
    @PreAuthorize("@ss.hasPermi('wlxz:record:add')")
    @Log(title = "学分补录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxzSupplementRecord wxzSupplementRecord)
    {
        return toAjax(wxzSupplementRecordService.insertWxzSupplementRecord(wxzSupplementRecord));
    }

    /**
     * 修改学分补录
     */
    @PreAuthorize("@ss.hasPermi('wlxz:record:edit')")
    @Log(title = "学分补录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxzSupplementRecord wxzSupplementRecord)
    {
        return toAjax(wxzSupplementRecordService.updateWxzSupplementRecord(wxzSupplementRecord));
    }

    /**
     * 删除学分补录
     */
    @PreAuthorize("@ss.hasPermi('wlxz:record:remove')")
    @Log(title = "学分补录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{supplementIds}")
    public AjaxResult remove(@PathVariable Long[] supplementIds)
    {
        return toAjax(wxzSupplementRecordService.deleteWxzSupplementRecordBySupplementIds(supplementIds));
    }
}
